<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <!-- Bootstrap -->
    <link href="static/bootstrap/css/bootstrap.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <title>新建下载任务</title>
</head>
<body>
<div class="container" style=" width: 800px;">
    <div class="panel panel-primary">
        <!-- Default panel contents -->
        <div class="panel-heading">新建任务</div>
        <div class="panel-body">
            这里你可以选择使用迅雷SDK或者Aria2。
            <hr/>
            <div class="form-horizontal" style="padding-right: 20px;">
                <div class="form-group">
                    <label class="col-sm-2 control-label">任务地址:</label>
                    <div class="col-sm-10">
                        <input type="text" name="new_url" class="form-control" placeholder="http://baidu.com/1.zip">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">Email</label>
                    <div class="col-sm-10">
                        <label class="radio-inline">
                            <input type="radio" name="new_back" value="0" checked> 迅雷
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="new_back" value="1"> Aria2
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button class="btn btn-primary" id="btn_add_task">添加任务</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="static/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="static/bootstrap/js/bootstrap.js"></script>

<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>  
<script type="text/javascript">
//Web initial loading 
var taskID = -1;
window.onload = function() { 
    new QWebChannel(qt.webChannelTransport, function(channel) { 
    
        //Get Qt interact object  
        var sdk_down = channel.objects.sdk_down; 
        
        //Web send message to Qt 
        document.getElementById("btn_add_task").onclick = function() {  
	        var thOrAira2=$("input:radio[name='new_back']:checked").val();
	        var urlStr = $("input:text[name='new_url']").val();
	        if( urlStr.length == 0 ){
		        return;
	        }
	        if( thOrAira2 == 0 ){
		        	sdk_down.CreateTaskTh(urlStr, function(nID){
	        		taskID = nID;
        		});
	        }else{
		        // Aria2
	        }
        	//sdk_down.QueryTaskTh2Json(taskID, function (msg) {
        	//	showmsg(msg);
        	//});        	
        };
 
    });  
} 
</script> 
</body>
</html>
